package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.PingjiaDetailBean;
import com.lwj.liwanjia.impl.PingjiaDetailView;
import com.lwj.liwanjia.model.PingjiaDetailModel;

import java.util.Map;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/9/30.
 */

public class PingjiaDetailPresenter {
    private PingjiaDetailView pingjiaDetailView;
    private PingjiaDetailModel pingjiaDetailModel;

    public PingjiaDetailPresenter(PingjiaDetailView pingjiaDetailView) {
        this.pingjiaDetailView = pingjiaDetailView;
        pingjiaDetailModel = new PingjiaDetailModel();
    }

    public void getPingjiaDetail(String token, String commentType, String commodityCode, String commodityType) {
        if (pingjiaDetailView != null) {
            pingjiaDetailModel.getPingjiaDetail(token, commentType, commodityCode, commodityType, new Subscriber<PingjiaDetailBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    pingjiaDetailView.showError((Exception) e);
                }

                @Override
                public void onNext(PingjiaDetailBean pingjiaDetailBean) {
                    pingjiaDetailView.getPingjiaDetal(pingjiaDetailBean);
                }
            });
        }
    }
}
